import { createRouter, createWebHistory } from "vue-router";
import type { RouteRecordRaw } from "vue-router"; // 仅类型导入
import HomeView from "../views/HomeView.vue";
import CurrencyExchangeView from "../views/CurrencyExchangeView.vue";
import NewsView from "../views/NewsView.vue";
import NewsDetailView from "../views/NewsDetailView.vue";
import Login from "../components/Login.vue";
import Register from "../components/Register.vue";

const routes: RouteRecordRaw[] = [
  { path: "/", name: "Home", component: HomeView },
  {
    path: "/exchange",
    name: "CurrencyExchange",
    component: CurrencyExchangeView,
  },
  { path: "/news", name: "News", component: NewsView },
  { path: "/news/:id", name: "NewsDetail", component: NewsDetailView },
  { path: "/login", name: "Login", component: Login },
  { path: "/register", name: "Register", component: Register },
  {
  path: '/signIn',
  name: 'SignIn',
  component: () => import('../views/SignInView.vue') // 假设你有一个视图组件
  },
  {
    path: '/profile',
    name: 'Profile', // 注意与 App.vue 中 index 值匹配规则（首字母大写）
     component: () => import('../views/UserProfileView.vue') // 假设你有一个视图组件
  },
  {
  path: '/posts/:id',
  name: 'PostDetail',
  component: () => import('../views/PostDetailView.vue')
  },
  {
  path: '/search/post',
  name: 'SearchPost',
  component: () => import('../views/SearchPostView.vue')
},
{
  path: '/user/posts',
  name: 'UserPosts',
  component: () => import('../views/UserPostsView.vue')
},
{
  path: '/user/post/:id/edit',
  name: 'EditPost',
  component: () => import('../views/EditPostView.vue') // 下一步创建
},
// router/index.ts
{
  path: '/post/:id',
  name: 'PostDetail',
  component: () => import('../views/PostDetailView.vue'),

},
];
const router = createRouter({
  history: createWebHistory(),
  routes,
});

export default router;